package com.lyc.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lyc.dao.GoodsDao;
import com.lyc.pojo.Goods;
import com.lyc.pojo.GoodsInfo;
import com.lyc.pojo.GoodsKinds;
import com.lyc.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("goodsService")
public class GoodsServiceImpl implements GoodsService {
    /*属性区*/
    @Autowired(required = false)
    private GoodsDao goodsDao;//私有属性

    /*方法区*/
    @Override//查询所有商品
    public List<Goods> selectAll() {
        return goodsDao.selectAll();
    }

    @Override//根据商品模糊查询
    public List<Goods> selectsp(String goodsKeyword) {

        return goodsDao.selectgoodsKeyword(goodsKeyword);
    }

    @Override
    public List<GoodsKinds> selectid1(Integer gkid) {
        return goodsDao.selectgkid(gkid);
    }
    @Override
    public List<GoodsKinds> selectid2(Integer gkid) {
        return goodsDao.selectgkid2(gkid);
    }
    @Override
    public List<GoodsKinds> selectid3(Integer gkid) {
        return goodsDao.selectgkid3(gkid);
    }

    @Override
    public Goods selectOne(int gid) {
        return goodsDao.selectOne(gid);
    }

    @Override
    public List<Goods> selectid4(int gkid) {
        return goodsDao.selectbase(gkid);
    }

    @Override
    public GoodsInfo selectGoodsInfo(int gid) {
        return goodsDao.selectGoodsInfo(gid);
    }

    @Override
    public List<GoodsKinds> selectid() {
        return goodsDao.selectid();
    }


    /*后台代码*/
    @Override
    public PageInfo<Goods> getGoodsByPage(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<Goods> goods=goodsDao.selectAll();
        return new PageInfo<>(goods);
    }

    @Override
    public int delete(int id) {
        return  goodsDao.delete(id);
    }

    @Override
    public int insert(Goods goods) {
        return goodsDao.insert(goods);
    }

    @Override
    public int update(Goods goods) {

        return goodsDao.update(goods);
    }

    @Override
    public int deleteSelect(List<String> list) {
        return goodsDao.deleteSelect(list);
    }

    @Override
    public List<Goods> selectByGmiaoshu(String gmiaoshu) {
        return goodsDao.selectByGmiaoshu(gmiaoshu);
    }

}
